package com.etc.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.etc.dao.DocumentMapper;
import com.etc.entity.Dept;
import com.etc.entity.Document;
import com.etc.service.DocumentService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

/**
 * 
 * @ClassName: DocumentServiceImpl
 * @Description: DocumentServiceImpl
 * @author knowno
 * @date 2022年4月7日 上午10:57:41
 *
 */
@Service
public class DocumentServiceImpl implements DocumentService {

	// 注入mapper
	@Autowired
	private DocumentMapper mapper;

	@Override
	public Page<Document> getByPage(int page, int limit, String keywords) {
		// 执行分页操作别忘记了
		PageHelper.startPage(page, limit);
		return mapper.getByLike("%" + keywords + "%");
	}

	@Override
	public int add(Document document) {
		// TODO Auto-generated method stub
		return mapper.insert(document);
	}

	@Override
	public int delete(int id) {
		// TODO Auto-generated method stub
		return mapper.deleteByPrimaryKey(id);
	}

	@Override
	public int update(Document document) {
		// TODO Auto-generated method stub
		return mapper.updateByPrimaryKeySelective(document);
	}

}
